package com.zr.ssm.mapper;

import com.zr.ssm.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

public interface UserMapper {

    @Insert("insert into ev_users(username, password) values (#{username},#{password})")
    int register(User user);

    @Select("select * from ev_users where username = #{username}")
    User selectByUsername(User user);

    @Select("select * from ev_users where id = #{id}")
    User selectById(Integer id);

    @Select("select * from ev_users where username = #{username} and password = #{password}")
    User selectSomeOne(User user);

    @Update("update ev_users set nickname = #{nickname}, email = #{email} where id = #{id}")
    int updateById(User user);

    @Update("update ev_users set password = #{newPwd} where id = #{id} ")
    int updatePwd(@Param("newPwd")String newPwd, @Param("id")Integer id);

    @Update("update ev_users set user_pic = #{avatar} where id = #{id} ")
    int updateAvatar(@Param("avatar")String avatar, @Param("id")Integer id);
}
